#!/usr/bin/env ruby

print "\n***** Simple-Chmod *****\n\nSyntax for changing permissions is 'none' or 'read write xcute' and leave out by choice.\n\nEnter filename or directory: "

require_relative 'simple-chmod/filechecker'
require_relative 'simple-chmod/perms'

STDOUT.flush
file = gets.chomp

check = Filechecker.new(file)
checker = check.result

if checker == true
  print "Filecheck OK.\nWhat permissions do you want to grant to the OWNER of this file?\n"
  STDOUT.flush
  ownerperms = gets.chomp
  chowperms = ChangePerms.new(ownerperms,'u',file)
  chowperms.result

  print "What permissions do you want to grant to the GROUP of this file?\n"
  STDOUT.flush
  groupperms = gets.chomp
  chgrpperms = ChangePerms.new(groupperms,'g',file)
  chgrpperms.result

  print "What permissions do you want to grant to the OTHERS?\n"
  STDOUT.flush
  otherperms = gets.chomp
  othrperms = ChangePerms.new(otherperms,'o',file)
  othrperms.result

else checker == false
  print "The file doesn't exist.\n"
end
